import { ObjCreate } from "../../common/ObjCreate";
import { ArenaCrossGroupCellRenderer } from "../cellRenderer/ArenaCrossGroupCellRenderer";
import { TitleItem } from "../../common/item/TitleItem";
import { Language } from "../../../../../extend/language/Language";
import { ObjTeamCreate } from "../../common/ObjTeamCreate";
import { ArenaCrossGroupPlayerCellRenderer } from "../cellRenderer/ArenaCrossGroupPlayerCellRenderer";
import { ArenaCrossGroupIdData } from "../arenaCrossData/ArenaCrossGroupIdData";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { DataProvider } from "../../../../../fl/data/DataProvider";
import { SArenaCrossGroupMembers } from "../../../../../Message/Public/SArenaCrossGroupMembers";
import { GroupMemberData } from "../arenaCrossData/GroupMemberData";
import { GTileList } from "../../../../../com/mui/controls/GTileList";
type int = number;
//class ArenaCrossGroupResultPanel
    
    export  class ArenaCrossGroupResultPanel /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.init();
            this.addEventListener(flash.events.Event.ADDED_TO_STAGE, this.onAddToStage);
            return;
        }

        /* internal  */onAddToStage(arg1: Object /* flash.events.Event */): void
        {
            this.getGroupPlayers();
            return;
        }

        /* internal  */init(): void
        {
            ObjCreate.createBg(0, 0, 319, 482, this);
            ObjCreate.createSpBannerAndBg(322, 0, 480, 482, "", this);
            this._tileListGroup = ObjCreate.createTileList(9, 9, 307, 473, this);
            this._tileListGroup.columnWidth = 147;
            this._tileListGroup.rowHeight = 54;
            this._tileListGroup.horizontalGap = 7;
            this._tileListGroup.verticalGap = 5;
            this._tileListGroup.addEventListener(flash.events.Event.CHANGE, this.onGroupSelectChange);
            this._tileListGroup.setStyle("cellRenderer", ArenaCrossGroupCellRenderer);
            var loc1=new Vector.<TitleItem>();
            loc1.push(new TitleItem(Language.getString(44242), 200));
            loc1.push(new TitleItem(Language.getString(44245), 95));
            loc1.push(new TitleItem(Language.getString(44244), 90));
            loc1.push(new TitleItem(Language.getString(44243), 95));
            var loc2=ObjTeamCreate.createTitles(loc1);
            ObjCreate.setObjAttri(loc2, 322, 8, -1, -1, this);
            this._tileListPlayer = ObjCreate.createTileList(327, 32, 470, 450, this);
            this._tileListPlayer.columnWidth = 470;
            this._tileListPlayer.rowHeight = 45;
            this._tileListPlayer.horizontalGap = 0;
            this._tileListPlayer.verticalGap = 0;
            this._tileListPlayer.setStyle("cellRenderer", ArenaCrossGroupPlayerCellRenderer);
            this.updateGroups();
            return;
        }

        /* internal  */onGroupSelectChange(arg1: Object /* flash.events.Event */): void
        {
            var loc1=null;
            if (this._tileListGroup.selectedItem) 
            {
                loc1 = this._tileListGroup.selectedItem as ArenaCrossGroupIdData;
                this._selectGroupId = loc1.groupId;
                this.getGroupPlayers();
            }
            return;
        }

        /* internal  */getGroupPlayers(): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.ArenaCrossGroupGetGroupPlayers, this._selectGroupId));
            return;
        }

        /* internal  */updateGroups(): void
        {
            var loc1=new Array<any>();
            var loc2=1;
            while (loc2 <= 16) 
            {
                loc1.push(new ArenaCrossGroupIdData(loc2, this._myGroupId));
                ++loc2;
            }
            this._tileListGroup.dataProvider = new DataProvider(loc1);
            if (this._tileListGroup.selectedIndex < 0 && loc1.length > 0) 
            {
                this._tileListGroup.selectedIndex = 0;
            }
            this._tileListGroup.drawNow();
            return;
        }

        public updateGroupMembers(arg1: SArenaCrossGroupMembers): void
        {
            var loc3=null;
            if (this._myGroupId == 0) 
            {
                this._myGroupId = arg1.myGroupId;
                this.updateGroups();
            }
            var loc1=[];
            var loc2=0;
            while (loc2 < arg1.members.length) 
            {
                loc3 = new GroupMemberData(arg1.myGroupId, arg1.members[loc2]);
                loc1.push(loc3);
                ++loc2;
            }
            this._tileListPlayer.dataProvider = new DataProvider(loc1);
            this._tileListPlayer.drawNow();
            return;
        }

        /* internal */ /* var */_tileListGroup: GTileList;

        /* internal */ /* var */_tileListPlayer: GTileList;

        /* internal */ /* var */_selectGroupId: int=1;

        /* internal */ /* var */_myGroupId: int=0;
    }
